/*
* @Author: xfy
* @Date:   2017-08-27 18:53:47
* @Last Modified by:   xfy
* @Last Modified time: 2017-08-29 22:43:01
*/
'use strict';
require('./index.css');
var _supper = require('util/supper.js');
var templateIndex = require('./index.string');
//侧边导航栏
var navSide = {
    option : {
        name : '',
        navList : [
            {name : 'user-center', desc : '个人中心', href : './user-center.html'},
            {name : 'user-pass-update', desc : '修改密码', href : './user-pass-update.html'},
            {name : 'about', desc : '关于', href : './about.html'}
        ]
    },
    init : function(option){
        //合并选项
        $.extend(this.option, option);
        this.renderNav();
    },
    //渲染导航菜单
    renderNav : function(){
        //计算active数据
        for(var i = 0, iLength = this.option.navList.length; i < iLength; i++){
            if(this.option.navList[i].name === this.option.name){
                this.option.navList[i].isActive = true;
            }
        };
        //渲染list数据
        var navHtml = _supper.renderHtml(templateIndex, {
            navList : this.option.navList
        });
        //把html放入容器
        $('.nav-side').html(navHtml);
    }
}
module.exports = navSide;